from django.db import models

from user.models import UserModel
from utils.BaseModel import BaseModel


# Create your models here.

class OrderModel(BaseModel):
    orderno = models.CharField(max_length=32, verbose_name='订单编号')
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE, verbose_name='用户')
    status = models.IntegerField(choices=((0, '待支付'), (1, '已支付'), (2, '已取消'), (3, '已评价')), default=0,
                                 verbose_name='订单状态')
    orderprice = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='订单价格')
    payprice = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='支付价格')
    patyype = models.IntegerField(choices=((0, '微信支付'), (1, '支付宝支付'), (2, '货到付款')), default=0,
                                  verbose_name='支付方式')
    paytime = models.DateTimeField(default=None, null=True, blank=True, verbose_name='支付时间')
    coupon = models.IntegerField(null=True, blank=True, verbose_name='优惠券')
    score = models.IntegerField(default=0, verbose_name='积分')
    payno = models.CharField(max_length=32, verbose_name='支付流水号', null=True, blank=True)

    class Meta:
        db_table = 'fgorder'


class OrderDetailModel(BaseModel):
    order = models.ForeignKey(OrderModel, on_delete=models.CASCADE, verbose_name='订单')
    coursename = models.CharField(max_length=255, verbose_name='课程名称')
    courseprice = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='课程价格')
    courseid = models.IntegerField(default=0, verbose_name='课程id')
    courseimg = models.CharField(max_length=255, verbose_name='课程图片')

    class Meta:
        db_table = 'fgorderdetail'
